.globl MBGetBaseAddress
MBGetBaseAddress:
	ldr r0, =0x2000B880
	mov pc, lr
.globl MBSendMsg
MBSendMsg:
	tst r0, #0xF
	movne pc, lr
	cmp r1, #15
	movhi pc, lr
	push {lr}
	msg .req r0
	channel .req r1
	add msg, channel
	orr msg, #0x40000000
	.unreq msg
	.unreq channel
	msg .req r1
	mov msg, r0
	baseAddress .req r0
	bl MBGetBaseAddress
	status .req r2
	send_wait:
		ldr status, [baseAddress,#0x18]
		tst status, #0x80000000
		bne send_wait
	.unreq status
	str msg, [baseAddress,#0x20]
	.unreq msg
	.unreq baseAddress
	pop {pc}
.globl MBReadMsg
MBReadMsg:
	cmp r1, #15
	movhi pc, lr
	push {lr}
	channel .req r1
	mov channel, r0
	baseAddress .req r0
	bl MBGetBaseAddress
	status .req r2
	read_wait:
		ldr status, [baseAddress, #0x18]
		tst status, #0x40000000
		bne read_wait
	.unreq status
	ldr r2, [baseAddress]
	rdChannel .req r3
	and rdChannel, r2, #0xF
	teq rdChannel, channel
	.unreq rdChannel
	bne read_wait
	.unreq baseAddress
	.unreq channel
	msg .req r0
	mov msg, r2
	and msg, #0xFFFFFFF0
	pop {pc}
